home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frm7_1_7
- Caption = "Character Count"
- ClientHeight = 1905
- ClientLeft = 1020
- ClientTop = 2160
- ClientWidth = 7365
- BeginProperty Font
- Name = "Times New Roman"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 1905
- ScaleWidth = 7365
- Begin VB.PictureBox picLetterCount
- BeginProperty Font
- Name = "Courier New"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1215
- Left = 2160
- ScaleHeight = 1155
- ScaleWidth = 4995
- TabIndex = 3
- Top = 600
- Width = 5055
- End
- Begin VB.CommandButton cmdAnalyze
- Caption = "Analyze Sentence"
- Default = -1 'True
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 120
- TabIndex = 2
- Top = 480
- Width = 1815
- End
- Begin VB.TextBox txtSentence
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 1200
- TabIndex = 1
- Top = 120
- Width = 6015
- End
- Begin VB.Label lblSentence
- Alignment = 1 'Right Justify
- Caption = "Sentence"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 975
- End
- Attribute VB_Name = "frm7_1_7"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub cmdAnalyze_Click()
- Dim index As Integer, letterNum As Integer, sentence As String
- Dim letter As String, column As Integer
- 'Count occurrences of different letters in a sentence
- ReDim charCount(Asc("A") To Asc("Z")) As Integer
- For index = Asc("A") To Asc("Z")
- charCount(index) = 0
- Next index
- 'Consider and tally each letter of sentence
- sentence = UCase(txtSentence.Text)
- For letterNum = 1 To Len(sentence)
- letter = Mid(sentence, letterNum, 1)
- If (letter >= "A") And (letter <= "Z") Then
- index = Asc(letter)
- charCount(index) = charCount(index) + 1
- End If
- Next letterNum
- 'List the tally for each letter of alphabet
- picLetterCount.Font = "Courier"
- picLetterCount.Cls
- column = 1 'Next column at which to display letter & count
- For letterNum = Asc("A") To Asc("Z")
- letter = Chr(letterNum)
- picLetterCount.Print Tab(column); letter;
- picLetterCount.Print Tab(column + 1); charCount(letterNum);
- column = column + 6
- If column > 42 Then 'only room for 7 sets of data in a line
- picLetterCount.Print
- column = 1
- End If
- Next letterNum
- End Sub
-